package bibliotecas;

import java.awt.*;

import javax.swing.*;

public class JSmartBar extends JMenuBar{

	private static final long serialVersionUID = -7379510121460300622L;
	
	public String menus[][] = null;
	
	public JSmartBar(){
		init();
	}
	
	public JSmartBar(String dados[][]){
		setMenu(dados);
		init();
	}
	
	private void init(){
		this.setBackground(new Color(150,150,150));
		if(System.getProperty("os.name").equals("Linux")){
			this.setFont(new Font("Ubuntu",0,14));
		}else{
			this.setFont(new Font("Arial",0,14));
		}
		this.setBorder(BorderFactory.createMatteBorder(0,0,0,0,new Color(0,0,0)));
	}
	
	public void setMenu(String dados[][]){
		menus = dados;
		menuInit(menus);
	}
	
	public void menuInit(String dados[][]){
		this.removeAll();
		for(int i = 0;i < dados.length;i++){
			if(dados[i][0] != null){
				this.add(new JMenu(dados[i][0]));
				if(System.getProperty("os.name").equals("Linux")){
					this.getMenu(i).setFont(new Font("Ubuntu",0,14));
				}else{
					this.getMenu(i).setFont(new Font("Arial",0,14));
				}
				for(int x = 1;x < dados[i].length;x++){
					if(dados[i][x] != null){
						this.getMenu(i).add(new JMenuItem(dados[i][x]));
						if(System.getProperty("os.name").equals("Linux")){
							this.getMenu(i).getItem(x - 1).setFont(new Font("Ubuntu",0,14));
						}else{
							this.getMenu(i).getItem(x - 1).setFont(new Font("Arial",0,14));
						}
					}
				}
			}
		}
	}

}
